Attribute VB_Name = "modVariables"
Option Explicit


Public Const HandCursor = 32649&
Public Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Public Choice As String
Public lTasksFlag As String

Declare Function vbEncodeIPtr Lib "p2smon.dll" (X As Object) As String
Declare Function CreateReportOnRuntimeDS Lib "p2smon.dll" (X As Object, ByVal reportPath$, ByVal fieldDefFilePath$, ByVal bOverWriteExistingFiles%, ByVal bLaunchDesigner%) As Integer
Declare Function OpenReportOnRuntimeDS Lib "p2smon.dll" (X As Object, ByVal reportPath$, ByVal fieldDefFilePath$, ByVal bOverWriteExistingFiles%, ByVal bLaunchDesigner%) As Integer
Declare Function CreateFieldDefFile Lib "p2smon.dll" (X As Object, ByVal fieldDefFilePath$, ByVal bOverWriteExistingFiles%) As Integer

'Container declaration - setting picturebox as parent
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'Public declarations
Public rs As New Recordset
Public objBox As TextBox
Public objCtl As Control
Public i As Integer
Public itmX
Public vBookMark As Variant
Public RepName As String
Public cString As String

Public cTypeVoucher As String '----use for non-trade , trade--

Public oString As New clsDeclaration

'**************************
Public cPartFilter As String
'**************************
Public lBoolean As Boolean
Public lCloseWindow As Boolean
Public lModal As Boolean
Public lSaving As Boolean
Public lPickListActive As Boolean
Public nCount As Long
Public sID As String
Public InvNum As String
Public ORnum As String
Public sFilterString As String

Public sCondition As String

Global Const sWOGenAcct = "" '" AND cType <> 'General' "

'Change transaction number variable
Public sNewTranNo As String

'Variables for connection
Public sUserName As String
Public sUserID As String
Public sUserDept As String
Public sDivision As String
'
'Public SecUserID As String
'Public SecUserRole As String
'Public SecUserName As String

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Use for Payable Setup Module
'Variable for Temporary container
Public vStrContainer1 As String
Public vStrContainer2 As String
Public vStrContainer3 As String
Public vStrContainer4 As String
Public vStrContainer5 As String
Public vStrContainer6 As String
Public vNumContainer1 As Double
Public vNumContainer2 As Double
Public vNumContainer3 As String
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public cTax As String
Public cEwtCode As String
Public cEwtrate As String


'Variable for Company ID
'Public COID As String
Public COName As String
Public sBankCode As String
Public sBankComp As String
Public sUnitId As String

Public sClient As String
Public cSQLFind As String

'Variable for Downloading
Public sDownload As String
Public sFilePath As String

'For Message Box Caption
Global Const msgTtl = "ComUnion"

'Pull-out slip option variable
Public lPullOutSlip As Boolean

'Pull-out slip option variable
Public lNoCanvass As Boolean

'*********************************
'System Report Global Variables
'By : Jon Fonacier
'*********************************
Public cReport As String
Public cReportTitle As String
Public cCompany As String
Public cAddress1 As String
Public cAddress2 As String
Public cCriteria1 As String
Public cCriteria2 As String
Public nVarInterval As Integer
Public cFilter As String
Public cFilter1 As String

Public gReportDataFrom As String
Public gReportDataTo As String
Public gReportFilterBy As String

Public gReportDateFrom As String
Public gReportDateTo As String
Public cReportName As String
Public cStorProcName As String
Public cFilePreview As String
Public cTypeReport As String

Public cID As String
Public cName As String
Public nLeadTime As Integer
Public nBuffer As Integer
Public nDaysFrom As Integer
Public nDaysTo As Integer
Public cWeek1From As String
Public cWeek1To As String
Public cWeek2From As String
Public cWeek2To As String
Public cWeek3From As String
Public cWeek3To As String
Public cWeek4From As String
Public cWeek4To As String
Public cWeek5From As String
Public cWeek5To As String

'*********************************
'Ad Hoc Report Form Variable
'*********************************
Public lAdHoc As Boolean
Public cCommand As String
Public nFileLen As Integer
Public CrystalApplication As CRAXDRT.Application
Public CrystalReport As CRAXDRT.Report
Public CrystalDatabase As CRAXDRT.Database
Public CrystalTables As CRAXDRT.DatabaseTables
Public CrystalTable As CRAXDRT.DatabaseTable
Public AdoRS As ADODB.Recordset
'*********************************
'Receipt Printing Report
'*********************************
Public cReceiptName As String
Public cModule As String
Public cSQL As String

'Approval Action variables
'*********************************
'From frmToolApproval
Enum eGAction
    G_Cancel
    G_OK
End Enum
Public gAction As eGAction ' Action as OK or Cancel
'
Public mSONo As String ' transaction number to be approved
Public mCode As String  ' customer/supplier that is/are subjected for the transaction

Public mlCApproved As Boolean ' boolean for approved credit details
Public mlPApproved As Boolean ' boolean for approved price details
'
Public mInboxRef As String
Public mInboxRefCode As String

Public mItemParent As String ' for parent node (tree view) selected

Enum eApprovalAction
    A_Approve
    A_Cancel
    A_Override
End Enum
Public mApprovalAction As eApprovalAction ' Approval Actions

'Public QApprovalRef As String ' Approval Canvass Reference
'*********************************
'logicglassupdate
Public cStrTypeHdr As String
Public cStrType As String

'Network Mapping
Public NM_LocalName As String
Public NM_RemoteName As String
Public NM_UserName As String
Public NM_Password As String

'For Approval Showform
Public lApprovalShow As Boolean
Public sFrmName As String
Public sTabTxt As String
Public sNodeCode As String
Public sNodeTxt As String
Public sLink As String
Public nNodeIndex As Integer
Public lClicked As Boolean

Public oContainer As New clsContainer

Public empHeight As Single
Public empWidth As Single


'Get User's Name
Public Sub GetUser(txt1 As Object, txt2 As Object)
On Error GoTo error_handler
Dim rsUser As New ADODB.Recordset

    Set rsUser = New ADODB.Recordset

    sSQL = "select (LastName + ', ' + FirstName + ' ' + MI) as Name from SEC_USER WHERE UserID = '" & sUserName & "'"
    rsUser.Open sSQL, cn, adOpenStatic, adLockOptimistic
    If rsUser.RecordCount > 0 Then
        txt1.Text = sUserName
        txt2.Text = rsUser!Name
    End If

    Set rsUser = Nothing

error_handler:
    Resume Next
End Sub

Public Function ColumnVisible(ColName As String, dtg As DataGrid) As Boolean
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
'        dtg.Columns(ColName).Visible = True
    End If
End Function

Public Function ObjectVisible(frm As Object, obj As Variant)
    Set frm = FrmName
    obj.Visible = False
End Function


Public Function ScreenResolution() As String
Dim iWidth As Integer, iHeight As Integer

iWidth = Screen.Width \ Screen.TwipsPerPixelX
iHeight = Screen.Height \ Screen.TwipsPerPixelY
ScreenResolution = iWidth & " X " & iHeight

End Function

' code get the value of tax rate
Public Function getTax() As Double
    Dim taxrate As Double
    taxrate = GetValueFrTable("cValue", "System_Option", "cCode = 'DEF_VAT_RATE'")
    taxrate = (1 + (taxrate / 100))
    getTax = taxrate
End Function
